
package com.apanal.qlife.app.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.apanal.qlife.app.dao.SoftwareVerMapper;
import com.apanal.qlife.app.model.SoftwareVer;
import com.apanal.qlife.app.service.AppService;
import com.apanal.qlife.common.page.Page;
import com.apanal.qlife.common.page.PageReturn;
import com.apanal.qlife.sys.dao.UserMapper;
import com.apanal.qlife.sys.model.User;

/**
 * @author Admin
 *
 */
@Service
public class AppServiceImpl implements AppService {
	
	@Autowired
	private UserMapper userMapper;
	
	@Autowired
	private SoftwareVerMapper verMapper;
	
	public PageReturn<User> findAppUserList(User user, Page page) 
	{
		int count = userMapper.selectAppUserListCount(user);
		List<User> list = userMapper.selectAppUserList(user,page);
		return new PageReturn<User>(list,count,page,user);
	}
	
	/**
	 * 查询App帐号
	 * @param user
	 * @param page
	 * @param model
	 * @return
	 */
	public User findAppUserInfo(User user)
	{
		return userMapper.selectByPrimaryKey(user.getUseId());
	}
	
	/**
	 * 查询版本List
	 * @param softwareVer
	 * @param page
	 * @return
	 */
	public PageReturn<SoftwareVer> findVersionList(SoftwareVer softwareVer,Page page)
	{
		int count = verMapper.findVersionListCount(softwareVer);
		List<SoftwareVer> list = verMapper.findVersionList(softwareVer,page);
		return new PageReturn<SoftwareVer>(list,count,page,softwareVer);
	}
	
	/**
	 * 保存版本信息
	 * @param record
	 * @return
	 */
	public int insertSelective(SoftwareVer softwareVer)
	{
		return verMapper.insertSelective(softwareVer);
	}
	
	/**
	 * 查询版本信息
	 * @param record
	 * @return
	 */
	public SoftwareVer findAppVersion(SoftwareVer softwareVer)
	{
		return verMapper.selectByPrimaryKey(softwareVer.getVerId());
	}
	
	/**
	 * 更新版本信息
	 * @param record
	 * @return
	 */
	public int updateAppVersion(SoftwareVer softwareVer)
	{
		return verMapper.updateByPrimaryKeySelective(softwareVer);
	}

}
